package 集合作业2;
import java.util.Scanner;
import com.company.Array;
import oop继承第一章.E;
import 集合作业1.Student;

import java.util.ArrayList;

public class TestEmployee {
    public static void main(String[] args) {

        Employee employee1=new Employee(1,"张三",18,3000);
        Employee employee2=new Employee(2,"李四",25,3500);
        Employee employee3=new Employee(3,"王五",22,3200);
        ArrayList<Employee> employees=new  ArrayList<>();
        employees.add(employee1);
        employees.add(employee2);
        employees.add(employee3);
        System.out.println("员工工号\t"+"员工姓名\t"+"员工年龄\t"+"员工工资\t");
        for (Employee employee:employees){
            System.out.println(employee.getId()+"\t\t"+employee.getName()+"\t\t"+employee.getAge()+"\t\t"+employee.getSalary());
        }
        /*
        *  在lisi之前插入一个员工，信息为：姓名：zhaoliu，年龄：24，工资3300
         */
        Scanner input=new Scanner(System .in );
        System.out.println("请输入学员工号：");
        int id= input.nextInt();
        System.out.println("请输入员工年龄：");
        int age = input.nextInt();
        System.out.println("请输入员工姓名：");
        String name = input.next();
        System.out.println("请输入员工工资：");
        double salary=input.nextDouble();
        Employee employee4=new Employee(id,name,age,salary);
        employees.add(1,employee4);
        System.out.println("员工工号\t"+"员工姓名\t"+"员工年龄\t"+"员工工资\t");
        for (Employee employee:employees){
            System.out.println(employee.getId()+"\t\t"+employee.getName()+"\t\t"+employee.getAge()+"\t\t"+employee.getSalary());
        }
        /*
        * 删除王五信息*/
        System.out.println("请输入要删除的员工的姓名：");
         String  name1=input.next();

        for (int i=0;i<employees.size();i++){
            if (name1.equals(employees.get(i).getName())) {
                employees.remove(i);
            }
        }
        for (Employee employee:employees){
            System.out.println(employee.getId()+"\t\t"+employee.getName()+"\t\t"+employee.getAge()+"\t\t"+employee.getSalary());
        }
    }
}
